<template>
    <div class="main">
      <section>
        <div class="btn-block">
          <input ref="file" type="file" class="upload-file" @change="up_file" style="display:none" id="fileUploadPDF"
            @click="(event)=> { event.target.value = null }"
            accept=".xls,.xlsx,.csv" value="导入" />
          <el-button type="primary" size="small" @click="$refs.file.click()">上传文件</el-button>
          <el-button type="primary" size="small" plain @click="down(1)">下载模板</el-button>
          <el-button type="success" size="small" plain @click="down(2)">帮助文档</el-button>
        </div>
      </section>
    </div>
</template>
<script>
    export default {
        name: 'clearAppCache',
        data(){
            return {
                btnLoading: false
            }
        },
        methods: {
          up_file(){
            let file = this.$refs.file.files[0];
            let formData = new FormData();
            formData.append("file", file);
            this.request({
              url: '/bsnl-product/manageregion/upload_city_data',
              method: 'post',
              data: formData
            }).then(res => {
              this.$message.success(res.message);
            })
          },
          down(type){
            if(type==1){
              window.location.href="https://qiniu.bisinuolan.cn/%E7%9C%81%E5%B8%82%E5%8C%BA%E6%A8%A1%E6%9D%BF.xlsx";
            }else if(type==2){
              window.location.href="https://qiniu.bisinuolan.cn/%E7%9C%81%E5%B8%82%E5%8C%BA%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3.docx";
            }
          }
        }
    }
</script>
